package com.flx.at.spring.code.test.testconditional;

import com.flx.at.spring.code.test.testconditional.component.Father;
import com.flx.at.spring.code.test.testconditional.component.Mother;
import com.flx.at.spring.code.test.testconditional.condition.RelationCondition;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Conditional;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: Fenglixiong
 * @Date: 2021/7/3 16:42
 * @Description:
 */
@Configuration
public class ConditionConfig {

    /**
     * 注释自己之后，mother类也不会被加载
     * @return
     */
    @Bean
    public Father father(){
        return new Father();
    }

    /**
     * 条件：当父类存在的时候，才会加载母亲类
     * @return
     */
    @Bean
    @Conditional(value = RelationCondition.class)
    public Mother mother(){
        return new Mother();
    }


}
